
//--------------------------------------------------------
// TABLE A13: Testing sorting between member-staff (Senate)
//--------------------------------------------------------

clear
use masterdata_senate.dta

gen ln_meansalary = ln(meansalary +1)
gen nolobstaff = numstaff - futurelob
gen femaleratio = numfemale/numstaff

gen dem =0
replace dem = 1 if party =="D"
replace dem = 1 if party =="I"

gen female = minwomen + majwomen

replace totbill = 0 if totbill==.
replace totimpbill = 0 if totimpbill ==.

sort icpsr congress
by icpsr, sort: gen numstaff_lag = numstaff[_n-1]
by icpsr, sort: gen nolobstaff_lag = nolobstaff[_n-1]
by icpsr, sort: gen salary_lag = ln_meansalary[_n-1]
by icpsr, sort: gen majority_lag = majority[_n-1]
by icpsr, sort: gen chair_lag = chair[_n-1]
by icpsr, sort: gen subchr_lag = subchr[_n-1]
by icpsr, sort: gen power_lag = power[_n-1]
by icpsr, sort: gen seniority_lag = seniority[_n-1]
by icpsr, sort: gen maj_leader_lag = maj_leader[_n-1]
by icpsr, sort: gen min_leader_lag = min_leader[_n-1]
by icpsr, sort: gen femaleratio_lag = femaleratio[_n-1]
by icpsr, sort: gen futurelob_lag = futurelob[_n-1]
by icpsr, sort: gen totbill_lag = totbill[_n-1]
by icpsr, sort: gen totimpbill_lag = totimpbill[_n-1]
by icpsr, sort: gen up_for_reelection_lag=up_for_reelection[_n-1]
by icpsr, sort: gen freshman_lag = freshman[_n-1]

macro define member_char1 "les_lag totbill_lag totimpbill_lag up_for_reelection_lag freshman_lag majority_lag chair_lag subchr_lag seniority_lag maj_leader_lag min_leader_lag power_lag dem membecamelob female afam latino state_leg south_dem"
macro define member_char2 "les_lag totbill_lag totimpbill_lag up_for_reelection_lag freshman_lag majority_lag chair_lag subchr_lag seniority_lag maj_leader_lag min_leader_lag power_lag"
macro define staff_char1 "numstaff_lag salary_lag femaleratio_lag"

eststo clear
eststo: quietly reg futurelob $member_char1 $staff_char1 i.congress, vce(cluster icpsr)
eststo: quietly areg futurelob $member_char2 $staff_char1 i.congress, a(icpsr) vce(cluster icpsr)
esttab, star(* 0.10 ** 0.05 *** 0.01) drop(*congress*) se ar2

